﻿
@{
    ViewBag.Title = "PlaceResponsibilityLevelList";
    Layout = "~/Views/Shared/_LayoutMain.cshtml";
}
@section css {
    <link href="~/Assets/css/lib/bootstrap-select.css" rel="stylesheet" />
    <link href="~/Assets/css/lib/bootstrap-datetimepicker.min.css" rel="stylesheet" />
    <link href="~/Assets/css/lib/fileinput.css" rel="stylesheet" />
    <style>
        th {
            text-align: center;
            font-weight: bold;
        }

        td {
            text-align: center;
            vertical-align: middle;
        }
    </style>
}
<div class="page-content" ng-cloak ng-controller="SafetyResponsibilityController" ng-init="SearchModel={};page='@(Request.QueryString["page"].IsEmpty() ? "1" : Request.QueryString["page"])';
     Id='@(Request.QueryString["Id"].IsEmpty() ? "0" : Request.QueryString["Id"])';
     PlaceName='@(Request.QueryString["PlaceName"].IsEmpty() ? "" : Request.QueryString["PlaceName"])';
     PageName='@Request.CurrentExecutionFilePath.Substring(Request.CurrentExecutionFilePath.LastIndexOf("/") + 1)';
     GetCheckInterval();
     ">
    <div class="load" ng-show="DataLoading">
        <div class="loader">
            <svg version="1.1" id="loader-1" x="0px" y="0px" width="100px" height="100px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
            <path fill="#000" d="M43.935,25.145c0-10.318-8.364-18.683-18.683-18.683c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615c8.072,0,14.615,6.543,14.615,14.615H43.935z">
            <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite" />
			</path>
		</svg>
            <div class="load-msg" ng-bind="LoadingMsg"></div>
        </div>
    </div>
    <div class="page-heading">
        <h1>{{PlaceName}}检查项设置</h1>
        <div class="options">
            <div class="btn-toolbar">

            </div>
        </div>
    </div>
    <ol class="breadcrumb">
        <li><a>主体业务</a></li>
        <li><a>安全责任</a></li>
        <li><a>场所责任</a></li>
        <li class="active"><a>检查项</a></li>
    </ol>

    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-12">
                <div class="panel panel-sky">
                    <div class="panel-heading">
                        <h2>{{PlaceName}}</h2>
                        <div class="panel-ctrls">
                            <div class="btn-group">
                                <a href="PlacePageList?page={{page}}" class="btn btn-xs btn-warning"><i class="fa fa-backward"></i>返回</a>
                            </div>
                        </div>
                    </div>
                    <div class="panel-body">
                        <form class="form-horizontal row-border">
                            <div class="form-group">
                                <label class="col-sm-1 control-label">检查频次：</label>
                                <div class="col-sm-8">
                                    <select class="form-control" ng-model="AddModel.Interval" ng-change="GetCheckItems(Id,AddModel.Interval)">
                                        <option ng-repeat="x in IntervalList" value="{{x.Id}}">{{x.IntervalName}}</option>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label">检查项：</label>
                                <div class="col-sm-8">
                                    <ul class="sortable-connected list-unstyled" id="SelectedCheckList">
                                        <li class="card-task card-info" id="{{x.OptionId}}" ng-repeat="x in CheckItemsList">
                                            <div class="card-handle"></div>
                                            <div class="card-title">
                                                <h3>{{$index+1}}.{{x.CheckContent}}</h3>
                                                <div class="card-done">{{$index+1}}/{{CheckItemsList.length}}</div>
                                            </div>
                                            <p class="card-desc">
                                                <span ng-if="!x.IsValue">定性</span>
                                                <span ng-if="x.IsValue">定量</span>
                                            </p>
                                            <div class="card-options">
                                                <div class="pull-left">
                                                </div>
                                                <div class="pull-right">
                                                    <div class="btn-group">
                                                        <a class="btn btn-default-alt btn-xs" ng-click="RemoveCheckOption(CheckItemsList,x);"><i class="fa fa-fw fa-times"></i></a>
                                                    </div>
                                                </div>
                                            </div>
                                        </li>
                                    </ul>
                                </div>
                                <div class="col-sm-1">
                                    <a data-toggle="modal" href="#CheckOptionModal" class="btn btn-primary">添加检查项</a>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="panel-footer">
                        <div class="col-sm-2">

                        </div>
                        <div class="col-sm-2">
                            <button type="button" class="btn btn-primary" ng-click="UpdateCheckItems(Id,AddModel.Interval);">提交</button>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="CheckOptionModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="min-width:1250px;">
            <div class="modal-content" style="min-height: 700px;">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h2 class="modal-title">选择检查项目</h2>
                </div>
                <div class="modal-body" style="min-height: 660px;">
                    <div class="row">
                        <div class="col-lg-6">
                            <div class="panel panel-default">
                                <div class="panel-heading"><h2>待选检查项</h2></div>
                                <div class="panel-body" style="height:100%;">
                                    <div class="row">
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" placeholder="检查项模糊搜索" ng-model="CheckOption.CheckCotent" ng-change="SearchCheckOptions(CheckOption.CheckCotent);" />
                                        </div>
                                        <div class="col-sm-3">
                                            <a class="btn btn-info" data-toggle="modal" href="#OptionModal">没有？添加</a>
                                        </div>
                                    </div>
                                    <div class="row" style="margin-top:20px;">
                                        <div class="col-sm-12">
                                            <div class="alert alert-inverse alert-info" style="padding:10px;" ng-show="OptionList==null || OptionList.length==0">
                                                无搜索结果...
                                            </div>
                                            <div class="alert alert-dismissable alert-info" style="padding:10px;" ng-repeat="x in OptionList">
                                                {{$index+1}}.{{x.CheckContent}}(<span ng-if="!x.IsValue">定性</span><span ng-if="x.IsValue">定量</span>)
                                                <button type="button" class="close" ng-click="SelectCheckOption(CheckItemsList,x);SearchCheckOptions(CheckOption.CheckCotent);">√</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-6">
                            <div class="panel panel-default">
                                <div class="panel-heading"><h2>已选检查项</h2></div>
                                <div class="panel-body panel-no-padding">
                                    <table id="example" class="table table-striped" cellspacing="0" width="100%">
                                        <tbody>
                                            <tr ng-show="CheckItemsList.length==0">
                                                <td colspan="3">
                                                    暂未选择检查项
                                                </td>
                                            </tr>
                                            <tr ng-repeat="y in CheckItemsList">
                                                <td>{{$index+1}}</td>
                                                <td style="text-align:left;">{{y.CheckContent}}</td>
                                                <td><button type="button" ng-click="RemoveCheckOption(CheckItemsList,y);">×</button></td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    <div class="modal fade" id="OptionModal" tabindex="-2" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" ng-init="OptionModel={};OptionModel.IsValue=false;">
        <div class="modal-dialog" style="min-width:650px;">
            <div class="modal-content" style="min-height: 600px;">
                <div class="modal-header">
                    <button type="button" class="close" id="close2" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h2 class="modal-title">添加项目</h2>
                </div>
                <div class="modal-body" style="min-height: 660px;">
                    <div class="row">
                        <form class="form-horizontal row-border">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">内容：</label>
                                <div class="col-sm-10">
                                    <textarea rows="5" class="form-control" ng-model="OptionModel.CheckContent"></textarea>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label"></label>
                                <div class="col-sm-10">
                                    <label class="radio-inline">
                                        <input type="radio" name="CheckOptionType" checked ng-click="OptionModel.IsValue=false" id="Type_0">定性
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="CheckOptionType"  ng-click="OptionModel.IsValue=true" id="Type_1">定量
                                    </label>
                                </div>
                            </div>

                        </form>
                    </div>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-primary" ng-click="AddCheckOption(OptionModel);">添加</button>
                </div>
            </div>
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
</div>


@section Js{
    <script src="~/Assets/js/pg/SafetyResponsibility.js?v=@DateTime.Now.ToString("yyMMddHH")"></script>
    <script>
        $('#SelectedCheckList').sortable({
            connectWith: ".sortable-connected",
            receive: function (event, ui) {
                var lists = $('.sortable-connected');
                for (var i = lists.length - 1; i >= 0; i--) {
                    if ($(lists[i]).children().length < 1) $(lists[i]).html('');
                };
            }
        });
    </script>
}
